#include "PageTable.h"

PageTable::PageTable() {
  entries = (PTEntry*) malloc((NUM_PAGES) * sizeof(PTEntry));
  if (entries == NULL) {
    printf("Not enough memory");
    exit(1);
  }

  //  Clear entries to 0
  for (long i = 0; i < NUM_PAGES; i++) {
    entries[i].frame = -1;
    entries[i].ref = 0;
    entries[i].dirty = 0;
    entries[i].time = 0;
  }
}

PTEntry PageTable::getPage(long page) {
  return entries[page];
}

void PageTable::setFrame(long ipage, int iframe) {
  entries[ipage].frame = iframe;
}
